<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>  
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>  
<%@ taglib prefix="gss" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>首頁</title>
	<link rel="stylesheet" type="text/css" href="css/jquery-ui.css" />
	<style type="text/css">
		body{font:12px/18px Tahoma; }
	</style>
</head>
<body>
<form id="form1" name="form1" method="post">
	<input type="button" value="新增" onclick="add()"/>
	<input type="submit" value="查詢" onclick="search()"/>
	店員查詢<input type="text" id="SName" name="SName" size="10" value="${SName}"/>
	<table border="1">
		<tr>
			<td>
				店員
			</td>
			<td>
				店員住址
			</td>
			<td>
				店員電話
			</td>
			<td>
				店員到職日
			</td>
			<td>
				所屬店
			</td>
			<td align="center">
				操作
			</td>
		</tr>
		<c:forEach items="${storeList }" var="list">
			<tr>
				<td>
					${list.SNAME }
				</td>
				<td>
					${list.SADDRESS }
				</td>
				<td>
					${list.STEL }
				</td>
				<td>
					${list.manager.PNAME}
				</td>
				<td>
					<c:forEach items="${list.staff}" var="staff" begin="0" end="${fn:length(list.staff) }" varStatus="count">
						${staff.PNAME }
						<c:if test="${fn:length(list.staff) ne count.index+1}">
							,
						</c:if>
					</c:forEach>
				</td>
				<td>
					<input type="submit" value="修改" onclick="modify('${list.SID}')"/>
					<input type="submit" value="刪除" onclick="deleteMethod('${list.SID}','${list.manager.PID}')"/>
				</td>
			</tr>
		</c:forEach>
	</table>
	<br/>
	<div style="width:850px">
		<gss:separatePage searchFormId="form1" />
	</div>
	<s:hidden name="SID"></s:hidden>
	<s:hidden name="PID"></s:hidden>
</form>

</body>
</html>
<script>
	//新增導頁
	function add(){
		location.href="action1!add2";
	}
	
	//修改導頁
	function modify(SID){
		document.getElementById("SID").value=SID;
		form1.action="action1!modify";
	}
	
	//刪除
	function deleteMethod(SID,PID){
		if(confirm("您確定要刪除?")){
			document.getElementById("SID").value=SID;
			document.getElementById("PID").value=PID;
			form1.action="action1!deleteMethod";
		}
	}
	
	//查詢
	function search(){
		form1.action="action1!select";
	}
</script>


